package com.yc.mybatis.damai.mapper;

import com.yc.mybatis.damai.bean.Product;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Company 源辰信息
 *
 * @author navy
 * @date 2024/7/25
 * Email haijunzhou@hnit.edu.cn
 */
public interface ProductMapper {

    @Select("select * from dm_product where pname like concat('%',#{name},'%')")
    @Results(id = "rm1",
            value = {
    //            <id column="id" property="id"></id>
                @Result(column = "id", property = "id", id = true),
//            <result column="market_price" property="marketPrice"></result>
//            <result column="shop_price" property="shopPrice"></result>
//            <result column="is_hot" property="isHot"></result>
                    @Result(column = "market_price", property = "marketPrice"),
                    @Result(column = "shop_price", property = "shopPrice"),
                    @Result(column = "is_hot", property = "isHot")
            })
    List<Product> selectByName(String name);

    @Select("select * from dm_product where pdesc like concat('%',#{desc},'%')")
    @ResultMap("rm1")
    List<Product> selectByDesc(String desc);

    @Select("select * from dm_product where id = #{id}")
    Product selectById(int id);

}
